import React, { useEffect, useState } from 'react'

export default function StrictCom() {
  //输出
  //创建一个状态
  let [count, setCount] = useState<number>(1);
  
  //useEffect 设置回调
  useEffect(() => {
    let timer = setInterval(() => {
      setCount(v => v + 1);
    }, 1000);

    //清理定时器
    return () => {
      clearInterval(timer);
    }
  }, []);

  return (
    <div>
      <h2>{count}</h2>
    </div>
  )
}
